

#include "CxType.h"
#include "CxMachine.h"
#include "CxGlobalVariable.h"
#include "CxUnitCard.h"
#include <boost/typeof/typeof.hpp>

using namespace MSG_SIGN;

//Init  the		machine
CxMachine::CxMachine(int nwidth,int  nheight):
					m_nheight(nheight),m_nwidth(nwidth),m_cardnumber(nwidth*nheight),
						m_unitcard(m_nheight),m_temper(0),m_tempershift(0)
{
	buildPart();
}


inline	void	CxMachine::buildPart()
{
	for(_UnitCardGroup::iterator i=m_unitcard.begin();i!=m_unitcard.end();++i)
	{	
		i->resize(m_nwidth);
		int number=0;
		for(BOOST_AUTO(j,i->begin());j!=i->end();++j)
		{
			*j=new CxUnitCard(number++);
		}
	}
}

CxMachine::~CxMachine()
{
}
void		CxMachine::setTime(const _Date &t)
{
	m_globalVar.getTime()->set(t);
}

boost::posix_time::ptime	CxMachine::rdTime()
{
	return m_globalVar.getTime()->getCurrent();
}
